#include "../include/ProfitReport.h"

ProfitReport::ProfitReport()
	: Report(), _userId() {};

ProfitReport::ProfitReport(const Poco::DateTime * const date, int id)
	: Report(date), _userId(id) {}

ProfitReport::~ProfitReport() {
	delete date;
}

//returns posotive int if this happens before other;
//negative if other happens before this; 0 otherwise.
//Two ProfitReport's of same date and user, are equal
int ProfitReport::compareTo(Events & other) const {
	int ans = 0;
	ans = (*(other.date) - *(this->date)).days(); //compare dates
	if (ans == 0) {//dates are the same
		ans = other.getType() - this->type;//compare event type
		if (ans == 0) { //event types are the same
			const ProfitReport &otherReport = dynamic_cast<ProfitReport&>(other); //cast other to ProfitReport
			ans = otherReport._userId - this->_userId; //compare user id
		}
	}
	return ans;
}

Events::eEvents ProfitReport::getType() const {
	return type;
}
